#!/bin/bash

wget https://github.com/docker/compose/releases/download/v2.27.1/docker-compose-linux-x86_64  -O /usr/local/bin/docker-compose
#配置docker-compose可执行权限
chmod  +x /usr/local/bin/docker-compose
docker-compose --version

#创建常用文件夹
mkdir -p /apps/soft/apache/maven/397
mkdir -p /apps/soft/jdk/corretto/{8,11,17,21}
mkdir -p /apps/soft/jdk/dragonwell/{8,11,17,21}
mkdir -p /apps/soft/go/22
mkdir -p /apps/soft/node/20
mkdir -p /apps/docker
mkdir -p /data/workspace/{javaProject,goProject,webProject}
mkdir -p /data/k8s
mkdir -p /data/docker
mkdir -p /data/download
mkdir -p /data/libs/{goLib,javaLib,nodeLib/node-cache,nodeLib/node-global}
mkdir -p /data/etcd

chmod 777 /data/etcd
chown zzhao:zzhao -R /apps
chown zzhao:zzhao -R /data


wget https://github.com/dragonwell-project/dragonwell8/releases/download/dragonwell-extended-8.19.20_jdk8u412-ga/Alibaba_Dragonwell_Extended_8.19.20_x64_linux.tar.gz  -O  /data/download/Alibaba_Dragonwell_Extended_8.19.20_x64_linux.tar.gz
wget https://github.com/dragonwell-project/dragonwell11/releases/download/dragonwell-standard-11.0.23.19_jdk-11.0.23-ga/Alibaba_Dragonwell_Standard_11.0.23.19.9_x64_linux.tar.gz -O  /data/download/Alibaba_Dragonwell_Standard_11.0.23.19.9_x64_linux.tar.gz
wget https://github.com/dragonwell-project/dragonwell17/releases/download/dragonwell-standard-17.0.11.0.12%2B9_jdk-17.0.11-ga/Alibaba_Dragonwell_Standard_17.0.11.0.12.9_x64_linux.tar.gz -O  /data/download/Alibaba_Dragonwell_Standard_17.0.11.0.12.9_x64_linux.tar.gz
wget https://github.com/dragonwell-project/dragonwell21/releases/download/dragonwell-standard-21.0.3.0.3%2B9_jdk-21.0.3-ga/Alibaba_Dragonwell_Standard_21.0.3.0.3.9_x64_linux.tar.gz -O  /data/download/Alibaba_Dragonwell_Standard_21.0.3.0.3.9_x64_linux.tar.gz

wget https://corretto.aws/downloads/latest/amazon-corretto-8-x64-linux-jdk.tar.gz -O  /data/download/amazon-corretto-8-x64-linux-jdk.tar.gz
wget https://corretto.aws/downloads/latest/amazon-corretto-11-x64-linux-jdk.tar.gz -O  /data/download/amazon-corretto-11-x64-linux-jdk.tar.gz
wget https://corretto.aws/downloads/latest/amazon-corretto-17-x64-linux-jdk.tar.gz -O  /data/download/amazon-corretto-17-x64-linux-jdk.tar.gz
wget https://corretto.aws/downloads/latest/amazon-corretto-21-x64-linux-jdk.tar.gz -O  /data/download/amazon-corretto-21-x64-linux-jdk.tar.gz

wget https://dlcdn.apache.org/maven/maven-3/3.9.7/binaries/apache-maven-3.9.7-bin.tar.gz -O  /data/download/apache-maven-3.9.7-bin.tar.gz
wget https://jaist.dl.sourceforge.net/project/sshpass/sshpass/1.10/sshpass-1.10.tar.gz -O  /data/download/sshpass-1.10.tar.gz



wget https://go.dev/dl/go1.22.4.linux-amd64.tar.gz -O  /data/download/go1.22.4.linux-amd64.tar.gz
wget https://nodejs.org/dist/v20.14.0/node-v20.14.0-linux-x64.tar.xz  -O  /data/download/node-v20.14.0-linux-x64.tar.xz




cd /data/download
tar -xvzf Alibaba_Dragonwell_Extended_8.19.20_x64_linux.tar.gz
tar -xvzf Alibaba_Dragonwell_Standard_11.0.23.19.9_x64_linux.tar.gz
tar -xvzf Alibaba_Dragonwell_Standard_17.0.11.0.12.9_x64_linux.tar.gz
tar -xvzf Alibaba_Dragonwell_Standard_21.0.3.0.3.9_x64_linux.tar.gz

dragonwell-11.0.23.19+9-GA/bin/jlink --module-path jmods --add-modules java.desktop --output dragonwell-11.0.23.19+9-GA/jre
dragonwell-17.0.11.0.12+9-GA/bin/jlink --module-path jmods --add-modules java.desktop --output dragonwell-17.0.11.0.12+9-GA/jre
dragonwell-21.0.3.0.3+9-GA/bin/jlink --module-path jmods --add-modules java.desktop --output dragonwell-21.0.3.0.3+9-GA/jre

mv -f dragonwell-8.19.20/* /apps/soft/jdk/dragonwell/8
mv -f dragonwell-11.0.23.19+9-GA/* /apps/soft/jdk/dragonwell/11
mv -f dragonwell-17.0.11.0.12+9-GA/* /apps/soft/jdk/dragonwell/17
mv -f dragonwell-21.0.3.0.3+9-GA/* /apps/soft/jdk/dragonwell/21



tar -xvzf amazon-corretto-8-x64-linux-jdk.tar.gz
tar -xvzf amazon-corretto-11-x64-linux-jdk.tar.gz
tar -xvzf amazon-corretto-17-x64-linux-jdk.tar.gz
tar -xvzf amazon-corretto-21-x64-linux-jdk.tar.gz

amazon-corretto-11.0.23.9.1-linux-x64/bin/jlink --module-path jmods --add-modules java.desktop --output amazon-corretto-11.0.23.9.1-linux-x64/jre
amazon-corretto-17.0.11.9.1-linux-x64/bin/jlink --module-path jmods --add-modules java.desktop --output amazon-corretto-17.0.11.9.1-linux-x64/jre
amazon-corretto-21.0.3.9.1-linux-x64/bin/jlink --module-path jmods --add-modules java.desktop --output amazon-corretto-21.0.3.9.1-linux-x64/jre

mv -f amazon-corretto-8.412.08.1-linux-x64/* /apps/soft/jdk/corretto/8
mv -f amazon-corretto-11.0.23.9.1-linux-x64/* /apps/soft/jdk/corretto/11
mv -f amazon-corretto-17.0.11.9.1-linux-x64/* /apps/soft/jdk/corretto/17
mv -f amazon-corretto-21.0.3.9.1-linux-x64/* /apps/soft/jdk/corretto/21


tar -xvzf apache-maven-3.9.7-bin.tar.gz
mv -f apache-maven-3.9.7 /apps/soft/apache/maven/397


tar xvzf sshpass-1.10.tar.gz
cd sshpass-1.10 ;./configure;make install
cd ../; rm -rf sshpass-1.10

tar -xvzf /data/download/go1.22.4.linux-amd64.tar.gz
mv -f go/* /apps/soft/go/22

tar -xvf /data/download/node-v20.14.0-linux-x64.tar.xz
mv -f node-v20.14.0-linux-x64/* /apps/soft/node/20



rm -rf /data/download/*

echo  -e  \#jdk >>  /etc/profile
echo  -e  export JAVA_HOME=/apps/soft/jdk/dragonwell/21 >>  /etc/profile
echo  -e  export JRE_HOME=\$JAVA_HOME/jre >>  /etc/profile
echo  -e  export PATH=\${PATH}:\$JAVA_HOME/bin:\$JRE_HOME/bin>>  /etc/profile

echo  -e  \#maven >>  /etc/profile
echo  -e  export MVN_HOME=/apps/soft/apache/maven/397 >>  /etc/profile
echo  -e  export PATH=\${PATH}:\${MVN_HOME}/bin >>  /etc/profile

echo  -e  \#GO >>  /etc/profile
echo  -e  export GOROOT=/apps/soft/go/22 >>  /etc/profile
echo  -e  export GOPATH=/data/libs/goLib >>  /etc/profile
echo  -e  export PATH=\${PATH}:\${GOROOT}/bin:\${GOPATH}/bin >>  /etc/profile


echo  -e  \#node >>  /etc/profile
echo  -e  export NODE_HOME=/apps/soft/node/20 >>  /etc/profile
echo  -e  export NODE_GLOBAL_HOME=/data/libs/nodeLib/node-global >>  /etc/profile
echo  -e  export PATH=\${PATH}:\${NODE_HOME}/bin:\${NODE_GLOBAL_HOME}/bin >>  /etc/profile

source /etc/profile

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
go env -w GOSUMDB="sum.golang.org"
go install github.com/goreleaser/goreleaser@latest
go install github.com/pilu/fresh@latest


npm config set prefix "/data/libs/nodeLib/node-global"
npm config set cache "/data/libs/nodeLib/node-cache"
npm config set registry https://registry.npmmirror.com
npm install -g yarn

java -version
go version
node -v
yarn -v
npm -v
mvn -v

